<section id="widget-grid" class="">
    <div class="row">
    	<div id="list-alert">
        </div>
    </div>
    <div class="row">
    	<article class="col-xs-8 col-sm-8 col-md-8 col-lg-4">
	    	<form class="form-inline">
	  			<div class="form-group">
	    			<label for="limitText"><strong>修改阈值(即时生效)</strong></label>
	    			<input type="number" class="form-control" id="limitText" placeholder="输入0~100的数字" value="80">
	  			</div>
			</form>
		</article>
    </div>
    <div class="row">
        <article class="col-xs-24 col-sm-24 col-md-24 col-lg-12">
            <table id="jqgrid"></table>
            <div id="pjqgrid"></div>
        </article>
    </div>
</section>
<script>
	var hostResourceData = [];
    pageSetUp();
    loadScript("js/plugin/jqgrid/grid.locale-en.min.js", function(){
    	loadScript("js/plugin/jqgrid/jquery.jqGrid.min.js", function(){
    		loadScript("js/create-jqgrid.js", function(){ 
    			sendGet("/upm_manager/v1.0/hosts?site="+getSession("siteId"),success,ListAlert,null);
    		});
    	});
    });
    
    function success(data){
    	hostResourceData = data.data;
    	createGridMonitorHostResource(data);
    }
    function forwardHostResourceDetail(id, statusText){
    	ListAlertClear();
    	if(statusText == '未入库'){
    		ListAlert("主机未入库,请先入库");
    		return false;
    	}
    	setSession('hostId', id);
    	
		window.location.href='index.html#views/monitor/host/monitor.html';
    }
    
    $('#limitText').on('change', function(e) {
    	setSession('hostResourceLimit', e.target.value);
    	$("#jqgrid").clearGridData().setGridParam({data: hostResourceData}).trigger("reloadGrid");
    });
    
    function showReturn(){
    	sendGet("/upm_manager/v1.0/hosts?site="+getSession("siteId"),success,ListAlert,null);
	}
    
    function reloadGrid(data){
	   	ListAlertClear();
	   	var jq_data=jq_data['data'];  	
	   	$("#jqgrid").clearGridData().setGridParam({data:jq_data}).trigger("reloadGrid");
    }
    
	clearInterval(flag);
	var flag = setInterval(showReturn, setTime);
</script>